package com.hui.xiao.xiaohui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.hui.xiao.xiaohui.ball.AsyncTaskTest;
import com.hui.xiao.xiaohui.ball.CustomView;
import com.hui.xiao.xiaohui.ball.SDStore;
import com.hui.xiao.xiaohui.fragment.BookFragmentActivity;
import com.hui.xiao.xiaohui.intent.ActionAttr;
import com.hui.xiao.xiaohui.intent.ActionData;
import com.hui.xiao.xiaohui.intent.IntentTab;
import com.hui.xiao.xiaohui.intent.SysAction;
import com.hui.xiao.xiaohui.io.CrudTest;
import com.hui.xiao.xiaohui.io.DBTest;
import com.hui.xiao.xiaohui.io.FileTest;
import com.hui.xiao.xiaohui.io.HttpTest;
import com.hui.xiao.xiaohui.io.SharePreferencesTest;
import com.hui.xiao.xiaohui.res.AnimationDrawable;
import com.hui.xiao.xiaohui.res.AnimationDrawableTest;
import com.hui.xiao.xiaohui.res.BitmapTest;
import com.hui.xiao.xiaohui.res.Blast;
import com.hui.xiao.xiaohui.res.ButterFly;
import com.hui.xiao.xiaohui.res.DrawViewTest;
import com.hui.xiao.xiaohui.res.LayerListTest;
import com.hui.xiao.xiaohui.res.MoveBack;
import com.hui.xiao.xiaohui.res.MyViewTest;
import com.hui.xiao.xiaohui.res.PathTest;
import com.hui.xiao.xiaohui.res.PathText;
import com.hui.xiao.xiaohui.res.ShaderTest;
import com.hui.xiao.xiaohui.res.TweenAnim;
import com.hui.xiao.xiaohui.res.ValuesResTest;
import com.hui.xiao.xiaohui.res.WarpTest;
import com.hui.xiao.xiaohui.ui.ActionBarTest;
import com.hui.xiao.xiaohui.ui.BaseAdapterTest;
import com.hui.xiao.xiaohui.ui.CalPrime;
import com.hui.xiao.xiaohui.ui.ClockUi;
import com.hui.xiao.xiaohui.ui.DateDialogTest;
import com.hui.xiao.xiaohui.ui.DialogTest;
import com.hui.xiao.xiaohui.ui.DialogTheme;
import com.hui.xiao.xiaohui.ui.EditUi;
import com.hui.xiao.xiaohui.ui.ImageSwitcherTest;
import com.hui.xiao.xiaohui.ui.NotificationTest;
import com.hui.xiao.xiaohui.ui.NumberPickerTest;
import com.hui.xiao.xiaohui.ui.PopupMenuTest;
import com.hui.xiao.xiaohui.ui.PopupWindowTest;
import com.hui.xiao.xiaohui.ui.ProgressBarTest;
import com.hui.xiao.xiaohui.ui.ProgressDialogTest;
import com.hui.xiao.xiaohui.ui.RatingBarTest;
import com.hui.xiao.xiaohui.ui.ScrollViewTest;
import com.hui.xiao.xiaohui.ui.SearchViewTest;
import com.hui.xiao.xiaohui.ui.SeekBarTest;
import com.hui.xiao.xiaohui.ui.TabHostTest;
import com.hui.xiao.xiaohui.ui.TextSwitcherTest;
import com.hui.xiao.xiaohui.ui.ToastTest;
import com.hui.xiao.xiaohui.ui.ViewFlipperTest;
import com.hui.xiao.xiaohui.ui.ViewSwitcherTest;
import com.hui.xiao.xiaohui.ui.ViewUi;
import com.hui.xiao.xiaohui.view.AdapterViewFilpperTest;
import com.hui.xiao.xiaohui.view.AutoCompleteText;
import com.hui.xiao.xiaohui.view.Caculator;
import com.hui.xiao.xiaohui.view.CalendarViewTest;
import com.hui.xiao.xiaohui.view.ChooseData;
import com.hui.xiao.xiaohui.view.ColorfulLight;
import com.hui.xiao.xiaohui.view.ExpandableListViewTest;
import com.hui.xiao.xiaohui.view.GalleryTest;
import com.hui.xiao.xiaohui.view.GridViewTest;
import com.hui.xiao.xiaohui.view.ManyView;
import com.hui.xiao.xiaohui.view.NetPicture;
import com.hui.xiao.xiaohui.view.SpinnerTest;
import com.hui.xiao.xiaohui.view.StackViewTest;
import com.hui.xiao.xiaohui.view.WebViewTest;
import com.hui.xiao.xiaohui.vo.Menu;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MainActivity extends Activity {

    Intent intent = new Intent();

    Menu[] menus = new Menu[]{
            new Menu("美女轮播图", "真的有美女哦", R.drawable.ok, LunBoActivtiy.class),
            new Menu("数据库增删改查", "IO", R.drawable.grow, CrudTest.class),
            new Menu("合金弹头", "拷贝的", R.drawable.grow, com.hui.xiao.xiaohui.metalslug.MainActivity.class),
            new Menu("文件读写", "IO", R.drawable.grow, FileTest.class),
            new Menu("数据库读写", "SQLite", R.drawable.grow, DBTest.class),
            new Menu("网页加载", "WebView", R.drawable.grow, WebViewTest.class),
            new Menu("网络链接", "URLConnection", R.drawable.grow, HttpTest.class),
            new Menu("配置读写", "SharePreferences的玩法", R.drawable.grow, SharePreferencesTest.class),
            new Menu("shader填充图形", "shader", R.drawable.grow, ShaderTest.class),
            new Menu("花朵绽放", "补间动画", R.drawable.grow, TweenAnim.class),
            new Menu("蝴蝶飞舞", "补间动画", R.drawable.grow, ButterFly.class),
            new Menu("爆炸动画", "逐帧动画", R.drawable.grow, Blast.class),
            new Menu("有一大波图片", "波动", R.drawable.grow, WarpTest.class),
            new Menu("功夫熊猫", "逐帧动画", R.drawable.grow, AnimationDrawableTest.class),
            new Menu("背景移动", "看飞机", R.drawable.grow, MoveBack.class),
            new Menu("手绘板", "画画儿", R.drawable.grow, DrawViewTest.class),
            new Menu("路径文本", "画画儿", R.drawable.grow, PathText.class),
            new Menu("路径绘图", "画画儿", R.drawable.grow, PathTest.class),
            new Menu("自定义绘图", "画画儿", R.drawable.grow, MyViewTest.class),
            new Menu("遍历资源图片", "Bitmap的读取", R.drawable.grow, BitmapTest.class),
            new Menu("自定义拖动条", "LayerList实现资源变换", R.drawable.grow, LayerListTest.class),
            new Menu("图片变形", "资源图片动画", R.drawable.grow, AnimationDrawable.class),
            new Menu("intent实现tab标签", "IntentTab属性", R.drawable.grow, IntentTab.class),
            new Menu("资源文件使用", "全是xml,烦", R.drawable.grow, ValuesResTest.class),
            new Menu("打开网页", "ActionData属性", R.drawable.grow, ActionData.class),
            new Menu("读取联系人", "启动系统应用", R.drawable.grow, SysAction.class),
            new Menu("action启动", "action启动", R.drawable.grow, ActionAttr.class),
            new Menu("sd卡储存", "sd卡储存", R.drawable.grow, SDStore.class),
            new Menu("fragment切换", "fragment用于局部替换", R.drawable.grow, BookFragmentActivity.class),
            new Menu("指尖小球", "随着手指移动的小球", R.drawable.grow, CustomView.class),
            new Menu("各种视图", "其实没几个", R.drawable.grow, ManyView.class),
            new Menu("霓虹灯", "赤橙黄绿青蓝紫", R.drawable.grow, ColorfulLight.class),
            new Menu("网络图片", "尝试失败,会闪退", R.drawable.grow, NetPicture.class),
            new Menu("计算器", "只是个样子,还不好看", R.drawable.grow, Caculator.class),
            new Menu("ui组件", "也没几个", R.drawable.grow, ViewUi.class),
            new Menu("可编辑组件", "希望是个友好的界面", R.drawable.grow, EditUi.class),
            new Menu("钟表组件", "时间飞升", R.drawable.grow, ClockUi.class),
            new Menu("自动补全", "可以自己提示的文本框", R.drawable.grow, AutoCompleteText.class),
            new Menu("图片预览", "网格视图", R.drawable.grow, GridViewTest.class),
            new Menu("可展开列表", "伸缩自如", R.drawable.grow, ExpandableListViewTest.class),
            new Menu("下拉列表框", "下拉的", R.drawable.grow, SpinnerTest.class),
            new Menu("画廊视图", "幻灯片是切换", R.drawable.grow, GalleryTest.class),
            new Menu("自动播放图片", "全自动", R.drawable.grow, AdapterViewFilpperTest.class),
            new Menu("栈视图", "进进出出", R.drawable.grow, StackViewTest.class),
            new Menu("进度条", "读取中...", R.drawable.grow, ProgressBarTest.class),
            new Menu("拖动条", "摩擦摩擦", R.drawable.grow, SeekBarTest.class),
            new Menu("星级评分条", "送你一颗星星", R.drawable.grow, RatingBarTest.class),
            new Menu("组件切换", "ViewSwitcher的玩法", R.drawable.grow, ViewSwitcherTest.class),
            new Menu("文本切换", "TextSwitcher的玩法", R.drawable.grow, TextSwitcherTest.class),
            new Menu("图片浏览器", "ImageSwitcher支持动画", R.drawable.grow, ImageSwitcherTest.class),
            new Menu("图片自动播放", "ViewFlipper支持组件切换动画", R.drawable.grow, ViewFlipperTest.class),
            new Menu("提示消息", "ToastTest的玩法", R.drawable.grow, ToastTest.class),
            new Menu("日期组件", "时间啊时间", R.drawable.grow, CalendarViewTest.class),
            new Menu("日期选择", "ChooseData", R.drawable.grow, ChooseData.class),
            new Menu("数值选择", "NumberPicker", R.drawable.grow, NumberPickerTest.class),
            new Menu("搜索框", "SearchView", R.drawable.grow, SearchViewTest.class),
            new Menu("选项卡", "TabHost", R.drawable.grow, TabHostTest.class),
            new Menu("滚动视图", "TabHost", R.drawable.grow, ScrollViewTest.class),
            new Menu("发送通知", "Notification", R.drawable.grow, NotificationTest.class),
            new Menu("各种对话框", "和你对话", R.drawable.grow, DialogTest.class),
            new Menu("对话框风格窗口", "未知", R.drawable.grow, DialogTheme.class),
            new Menu("弹出Popup窗口", "PopupWindow", R.drawable.grow, PopupWindowTest.class),
            new Menu("时间的弹窗", "时间弹窗选择", R.drawable.grow, DateDialogTest.class),
            new Menu("进度的弹窗", "显示进度", R.drawable.grow, ProgressDialogTest.class),
            new Menu("弹出菜单", "PopupMenu", R.drawable.grow, PopupMenuTest.class),
            new Menu("工具条", "ActionBar", R.drawable.grow, ActionBarTest.class),
            new Menu("计算质数", "Handler和线程的使用", R.drawable.grow, CalPrime.class),
            new Menu("异步下载", "AsyncTask", R.drawable.grow, AsyncTaskTest.class),
            new Menu("列表视图", "菜单就是这么做的", R.drawable.grow, BaseAdapterTest.class)
    };

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list_adapter);
        List<Map<String, Object>> items = new ArrayList<>();
        for (int i = 0; i < menus.length; i++) {
            Map<String, Object> item = new HashMap<>();
            item.put("header", menus[i].getHeader());
            item.put("name", menus[i].getName());
            item.put("desc", menus[i].getDesc());
            items.add(item);
        }
        SimpleAdapter simpleAdapter = new SimpleAdapter(this, items,
                R.layout.simple_item, new String[]{"name", "header", "desc"},
                new int[]{R.id.name, R.id.header, R.id.desc});
        ListView list = (ListView) findViewById(R.id.mylist);
        list.setAdapter(simpleAdapter);
        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                intent.setClass(MainActivity.this, menus[position].getClazz());
                startActivity(intent);
            }
        });
    }
}
